package top.fangw.admin.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import top.fangw.admin.pojo.entity.SysUserJoinOrg;
import top.fangw.admin.mapper.SysUserJoinOrgMapper;
import top.fangw.admin.service.ISysUserJoinOrgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.fangw.common.api.vo.InitUserJoinOrgVo;
import top.fangw.common.mybatis.annotation.DyDataSource;

/**
 * <p>
 * 用途：存储用户和机构的关联信息 服务实现类
 * </p>
 *
 * @author fangw
 * @since 2024-03-02
 */
@Service
@DS("base_info")
public class SysUserJoinOrgServiceImpl extends ServiceImpl<SysUserJoinOrgMapper, SysUserJoinOrg> implements ISysUserJoinOrgService {

    @Override
    @DyDataSource(tenantId = "#initUserJoinOrg.tenantId", autoTenantId = false)
    public void initUserJoinOrg(InitUserJoinOrgVo initUserJoinOrg) {
        SysUserJoinOrg sysUserJoinOrg = BeanUtil.copyProperties(initUserJoinOrg, SysUserJoinOrg.class);
        this.baseMapper.insert(sysUserJoinOrg);
    }

    @Override
    public void deleteByOrgId(String orgId) {
        this.baseMapper.deleteByOrgId(orgId);
    }
}
